public class DuckTest {
    public static void main(String[] args){
        System.out.println("===鸭子继承体系演示===\n");

        //1.创建父类鸭子对象
        System.out.println("1.父类鸭子：");
        Duck basicDuck = new Duck("灰色",1.5);
        basicDuck.displayInfo();
        basicDuck.fly();
        basicDuck.quack();
        basicDuck.setHeavy(1.8);
        System.out.println();

        //2.创建绿头鸭子对象
        System.out.println("2.绿头鸭子：");
        MallardDuck mallard = new MallardDuck();
        mallard.displayInfo();
        mallard.fly();
        mallard.quack();
        mallard.setHeavy(1.3);
        mallard.setHeavy(1300,"g");
        mallard.setHeavy(1.0,1.5);
        System.out.println();

        //3.创建北京鸭子对象
        System.out.println("3.北京鸭子：");
        PekingDuck pekingDuck = new PekingDuck();
        pekingDuck.displayInfo();
        pekingDuck.fly();
        pekingDuck.quack();
        pekingDuck.setHeavy(2.8);
        pekingDuck.setHeavy(3.0,true);
        pekingDuck.setCanFly(true);
        pekingDuck.fly();
        System.out.println();

        //4.多态演示
        System.out.println("4.多态演示：");
        Duck[] ducks = new Duck[3];
        ducks[0] = new Duck("黄色",1.0);
        ducks[1] = new MallardDuck();
        ducks[2] = new PekingDuck();

        for (Duck duck : ducks){
            duck.fly();
            duck.quack();
            System.out.println("---");
        }
    }
}
